package cn.com.simple.learning.mybatisplus.service;

import cn.com.simple.learning.core.entity.Order;
import cn.com.simple.learning.mybatisplus.mapper.OrderMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author Jianxing.Jia
 * @date 2022/1/28
 * @description 批量添加
 */
@Service
public class OrderService extends ServiceImpl<OrderMapper, Order> {

	@Transactional(rollbackFor = Exception.class)
	public Integer batchSave(List<Order> orders) {
		if (CollectionUtils.isEmpty(orders)) {
			return 0;
		}
		return this.baseMapper.insertBatchSomeColumn(orders);
	}

}
